package ai.people.netmon.telegram.controller;

import ai.people.netmon.framework.domain.telegram.vo.channels.ChannelsView;
import ai.people.netmon.framework.model.response.PageResponse;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.telegram.domain.request.SearchAccountChannelRequest;
import ai.people.netmon.telegram.domain.request.channels.ChannelsRequest;
import ai.people.netmon.telegram.service.ChannelsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 群组
 *
 * @author yuanqinglong
 * @date 2022/1/10 9:57
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/channels")
public class ChannelsController {

    @Autowired
    private ChannelsService channelsServiceImpl;


    /**
     * 业务线索分页查询
     *
     * @param channelsRequest 查询条件
     * @return {@link Result}<{@link PageResponse}<{@link ChannelsView}>>
     */
    @PostMapping("/business/channelsList")
    public Result<PageResponse<ChannelsView>> queryChannelPage(@RequestBody ChannelsRequest channelsRequest) {
        PageResponse<ChannelsView> channelsViewPageResponse = channelsServiceImpl.businessChannelsList(channelsRequest);
        return ResultUtil.success(channelsViewPageResponse);
    }



    /**
     * 搜索群组
     *
     * @param searchChannelsRequest 搜索群组请求
     * @return {@link Result}
     */
    @PostMapping("/search/channelsList")
    public Result<PageResponse<ChannelsView>> searchAccount(@RequestBody SearchAccountChannelRequest searchChannelsRequest) {

        return ResultUtil.success(channelsServiceImpl.searchChannels(searchChannelsRequest));
    }

}
